<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!doctype html>
<html>
	<head>
		<title>日志记录查询</title>
		<base href="<%=basePath%>" />
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta name="renderer" content="webkit">
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<link rel="stylesheet" href="layui/css/layui.css">
		<style type="text/css">
		</style>

	</head>

	<body>
	    <br/>
		<div class="layui-form" id="table-list">
			<table class="layui-table" lay-skin="nob" id="Operate" lay-filter="Operate"></table>
		</div>
        
		<script src="js/jquery.min.js"></script>
		<script src="layui/layui.js"></script>
		<script src="js/frame/form_upload.js"></script>
		<script src="js/frame/datagrid.js"></script>
		<script id="createTime" type="text/html">
            {{#   }}
                <span>{{ new Date(d.createTime).toLocaleString() }}</span>
            {{#   }}
        </script>
        <script id="eventexplain" type="text/html">
            {{# if (d.eventexplain === "0") { }}
                <span>\</span>
            {{# } else {  }}
                <span>{{ d.eventexplain }}</span>
            {{# } }}
        </script>
        <script id="userid" type="text/html">
            {{# if (d.userid === 0) { }}
                <span>\</span>
            {{# } else {  }}
                <span>{{ d.userid }}</span>
            {{# } }}
        </script>
		<script>
			layui.use(['layer', 'form', 'table', 'laytpl','laydate'], function() {
				var layer = layui.layer,
					form = layui.form,
					table = layui.table,
					laytpl = layui.laytpl
					laydate = layui.laydate;

				layer.config({
					extend: 'MySkin/style.css'
				});

				//加个table表
				table.render({
					elem: '#Operate',
					url: 'Operate/query',
					method: 'post',
					title: '日志查询列表',
					totalRow: true,
					cellMinWidth: 50, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
					id: 'AllTable',
					request: {
						pageName: 'PageIndex',
						limitName: 'PageCount'
					},
					cols: [[
						{field: 'adminname',title: '管理员昵称'}, 
						{field: 'serviceName',title: '操作说明'},
						{field: 'eventexplain',title: '记录详述',templet:'#eventexplain',style:'color:#ed1941;'}, 
						{field: 'createTime',title: '操作时间',templet:'#createTime',style:'color:#1d953f;'},
						{field: 'userid',title: '操作用户',templet:'#userid',style:'color:#fcaf17;'}, 
						{field: 'operResult',title: '操作结果'}, 
						{field: 'ip',title: '操作IP',style:'color:#45b97c;'}
						]],
					page: true, //分页
					response: {
						statusCode: 200
						//重新规定成功的状态码为 200，table 组件默认为 0
					},
					parseData: function(res) { //将原始数据解析成 table 组件所规定的数据
						return {
							"code": res.status, //解析接口状态
							"msg": res.message, //解析提示文本
							"count": res.count, //解析数据长度
							"data": res.data //解析数据列表
							//解析数据列表
						};
					}
				});
				
				//根据条件查询表格数据重新加载
				var active = {
					reload: function() {
					//获取用户名
					//执行重载
					table.reload('AllTable', {page: {curr: 1}});
					return false;
					}
				};
				//点击搜索按钮根据用户名称查询
				$('#findID').on('click',
					function() {
						var type = $(this).data('type');
						active[type] ? active[type].call(this) : '';
					});

                setInterval(function(){
                	table.reload('AllTable', {});
                },60000);
			});
		</script>
	</body>
</html>
